<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="用户姓名" prop="memberName">
        <el-input
          v-model="queryParams.memberName"
          placeholder="请输入用户姓名"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="密码(未启用)" prop="password" v-if="false">
        <el-input
          v-model="queryParams.password"
          placeholder="请输入密码(未启用)"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="成员等级" prop="memberLevel" v-if="false">
        <el-select v-model="queryParams.memberLevel" placeholder="请选择成员等级" clearable>
          <el-option
            v-for="dict in cl_member_level"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="成员学历" prop="memberEdu" v-if="false">
        <el-select v-model="queryParams.memberEdu" placeholder="请选择成员学历" clearable>
          <el-option
            v-for="dict in cl_member_edu"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="成员民族" prop="memberNationality" v-if="false">
        <el-input
          v-model="queryParams.memberNationality"
          placeholder="请输入成员民族"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="籍贯" prop="nativePlace" v-if="false">
        <el-input
          v-model="queryParams.nativePlace"
          placeholder="请输入籍贯"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="血型" prop="bloodType" v-if="false">
        <el-select v-model="queryParams.bloodType" placeholder="请选择血型" clearable>
          <el-option
            v-for="dict in cl_blood_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="政治面貌" prop="political" v-if="false">
        <el-select v-model="queryParams.political" placeholder="请选择政治面貌" clearable>
          <el-option
            v-for="dict in cl_political_type"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label=" 1 男 0 女 2未知" prop="sex" v-if="false">
        <el-select v-model="queryParams.sex" placeholder="请选择 1 男 0 女 2未知" clearable>
          <el-option
            v-for="dict in cl_sex"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="生日" prop="birthday" v-if="false">
        <el-date-picker clearable
          v-model="queryParams.birthday"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择生日">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="所在城市" prop="city" v-if="false">
        <el-input
          v-model="queryParams.city"
          placeholder="请输入所在城市"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所在行业" prop="industry" v-if="false">
        <el-input
          v-model="queryParams.industry"
          placeholder="请输入所在行业"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="所在单位" prop="company" v-if="false">
        <el-input
          v-model="queryParams.company"
          placeholder="请输入所在单位"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="自我介绍" prop="introduction" v-if="false">
        <el-input
          v-model="queryParams.introduction"
          placeholder="请输入自我介绍"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="邮箱" prop="email" v-if="false">
        <el-input
          v-model="queryParams.email"
          placeholder="请输入邮箱"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机号码" prop="mobile">
        <el-input
          v-model="queryParams.mobile"
          placeholder="请输入手机号码"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="身份证号码" prop="idCard" v-if="false">
        <el-input
          v-model="queryParams.idCard"
          placeholder="请输入身份证号码"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="是否被锁定冻结" prop="isLock" v-if="false">
        <el-input
          v-model="queryParams.isLock"
          placeholder="请输入是否被锁定冻结"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="判断由哪个成员介绍进入" prop="firstLeader" v-if="false">
        <el-input
          v-model="queryParams.firstLeader"
          placeholder="请输入判断由哪个成员介绍进入"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用于app 授权类似于session_id" prop="token" v-if="false">
        <el-input
          v-model="queryParams.token"
          placeholder="请输入用于app 授权类似于session_id"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="注册时间" prop="regTime" v-if="false">
        <el-date-picker clearable
          v-model="queryParams.regTime"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择注册时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="最后登录时间" prop="lastLogin" v-if="false">
        <el-date-picker clearable
          v-model="queryParams.lastLogin"
          type="date"
          value-format="YYYY-MM-DD"
          placeholder="请选择最后登录时间">
        </el-date-picker>
      </el-form-item>
      <el-form-item label="最后登录ip" prop="lastIp" v-if="false">
        <el-input
          v-model="queryParams.lastIp"
          placeholder="请输入最后登录ip"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="地址" prop="address" v-if="false">
        <el-input
          v-model="queryParams.address"
          placeholder="请输入地址"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="居住地所在区域" prop="area" v-if="false">
        <el-input
          v-model="queryParams.area"
          placeholder="请输入居住地所在区域"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="审核状态" prop="status">
        <el-select v-model="queryParams.status" placeholder="请选择审核状态" clearable>
          <el-option
            v-for="dict in cl_examine_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button  v-if="false"
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['ndpf:member:add']"
        >新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button  v-if="false"
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['ndpf:member:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button  v-if="false"
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['ndpf:member:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button  v-if="false"
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['ndpf:member:export']"
        >导出</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          @click="handleExaminePrePass"
          v-hasPermi="['ndpf:member:examinePrePass']"
        >批量预审</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          @click="handleExamineRefuse"
          v-hasPermi="['ndpf:member:examineRefuse']"
        >批量驳回</el-button>
      </el-col>
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="memberList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column label="表id" align="center" prop="memberId" v-if="false"/>
      <el-table-column label="用户编号" align="center" prop="memberSn" />
      <el-table-column label="用户姓名" align="center" prop="memberName" />
      <el-table-column label="密码(未启用)" align="center" prop="password" v-if="false"/>
      <el-table-column label="成员等级" align="center" prop="memberLevel" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_member_level" :value="scope.row.memberLevel"/>
        </template>
      </el-table-column>
      <el-table-column label="成员学历" align="center" prop="memberEdu" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_member_edu" :value="scope.row.memberEdu"/>
        </template>
      </el-table-column>
      <el-table-column label="成员民族" align="center" prop="memberNationality" v-if="false"/>
      <el-table-column label="籍贯" align="center" prop="nativePlace" v-if="false"/>
      <el-table-column label="血型" align="center" prop="bloodType" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_blood_type" :value="scope.row.bloodType"/>
        </template>
      </el-table-column>
      <el-table-column label="政治面貌" align="center" prop="political" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_political_type" :value="scope.row.political"/>
        </template>
      </el-table-column>
      <el-table-column label=" 1 男 0 女 2未知" align="center" prop="sex" v-if="false">
        <template #default="scope">
          <dict-tag :options="cl_sex" :value="scope.row.sex"/>
        </template>
      </el-table-column>
      <el-table-column label="生日" align="center" prop="birthday" width="180" v-if="false">
        <template #default="scope">
          <span>{{ parseTime(scope.row.birthday, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="所在城市" align="center" prop="city" v-if="false"/>
      <el-table-column label="所在行业" align="center" prop="industry" v-if="false"/>
      <el-table-column label="所在单位" align="center" prop="company" v-if="false"/>
      <el-table-column label="自我介绍" align="center" prop="introduction" v-if="false"/>
      <el-table-column label="邮箱" align="center" prop="email" />
      <el-table-column label="手机号码" align="center" prop="mobile" />
      <el-table-column label="是否验证手机" align="center" prop="mobileValidated" v-if="false"/>
      <el-table-column label="身份证号码" align="center" prop="idCard" v-if="false"/>
      <el-table-column label="是否验证身份证号码" align="center" prop="idValidated" v-if="false"/>
      <el-table-column label="头像" align="center" prop="headPic" width="100" v-if="false">
        <template #default="scope">
          <image-preview :src="scope.row.headPic" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="证件照" align="center" prop="cardPhoto" width="100" v-if="false">
        <template #default="scope">
          <image-preview :src="scope.row.cardPhoto" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="生活照" align="center" prop="photo" width="100" v-if="false">
        <template #default="scope">
          <image-preview :src="scope.row.photo" :width="50" :height="50"/>
        </template>
      </el-table-column>
      <el-table-column label="是否被锁定冻结" align="center" prop="isLock" v-if="false"/>
      <el-table-column label="判断由哪个成员介绍进入" align="center" prop="firstLeader" v-if="false"/>
      <el-table-column label="用于app 授权类似于session_id" align="center" prop="token" v-if="false"/>
      <el-table-column label="注册时间" align="center" prop="regTime" width="180" v-if="false">
        <template #default="scope">
          <span>{{ parseTime(scope.row.regTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最后登录时间" align="center" prop="lastLogin" width="180" v-if="false">
        <template #default="scope">
          <span>{{ parseTime(scope.row.lastLogin, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="最后登录ip" align="center" prop="lastIp" v-if="false"/>
      <el-table-column label="是否验证审核认证" align="center" prop="idAudit" v-if="false"/>
      <el-table-column label="积分" align="center" prop="score" />
      <el-table-column label="服务时长" align="center" prop="totalService" />
      <el-table-column label="地址" align="center" prop="address" v-if="false"/>
      <el-table-column label="居住地所在区域" align="center" prop="area" v-if="false"/>
      <el-table-column label="已审核通过" align="center" prop="status">
        <template #default="scope">
          <dict-tag :options="cl_examine_status" :value="scope.row.status"/>
        </template>
      </el-table-column>
      <el-table-column label="备注" align="center" prop="remark" v-if="false"/>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="250px">
        <template #default="scope">
          <el-button type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['ndpf:member:examinePrePass']">查看</el-button>
          <el-button type="success" @click="handleExaminePrePass(scope.row)" v-hasPermi="['ndpf:member:examinePrePass']" v-if="scope.row.status === '0'">通过</el-button>
          <el-button type="warning" @click="handleExamineRefuse(scope.row)" v-hasPermi="['ndpf:member:examinePrePass']" v-if="scope.row.status === '0'">驳回</el-button>
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改成员信息对话框 -->
    <el-dialog :title="title" v-model="open" width="1200px" append-to-body>
      <el-form ref="memberRef" :model="form" :rules="rules" label-width="120px">.
        <el-row>
          <el-col :span="8">
            <el-form-item label="头像" prop="headPic">
              <image-preview :src="form.headPic" :width="50" :height="50"/>
              <!-- <image-upload v-model="form.headPic"/> -->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="证件照" prop="cardPhoto">
              <image-preview :src="form.cardPhoto" :width="50" :height="50"/>
              <!-- <image-upload v-model="form.cardPhoto"/> -->
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="生活照" prop="photo">
              <image-preview :src="form.photo" :width="50" :height="50"/>
              <!-- <image-upload v-model="form.photo"/> -->
            </el-form-item>
            </el-col>
          <el-col :span="6">
            <el-form-item label="用户姓名" prop="memberName">
              <el-input v-model="form.memberName" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成员等级" prop="memberLevel">
              <el-select v-model="form.memberLevel" placeholder="" disabled>
                <el-option
                  v-for="dict in cl_member_level"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"               
                  style="background-color: #f50c0c"
                ></el-option>
              </el-select>          
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成员学历" prop="memberEdu">
              <el-select v-model="form.memberEdu" placeholder="" disabled >
                <el-option
                  v-for="dict in cl_member_edu"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="成员民族" prop="memberNationality">
              <el-input v-model="form.memberNationality" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="籍贯" prop="nativePlace">
              <el-input v-model="form.nativePlace" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="血型" prop="bloodType">
              <el-select v-model="form.bloodType" placeholder="" disabled>
                <el-option
                  v-for="dict in cl_blood_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="政治面貌" prop="political">
              <el-select v-model="form.political" placeholder="" disabled>
                <el-option
                  v-for="dict in cl_political_type"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="特长" prop="talent">
              <el-checkbox-group v-model="form.talent">
                <el-checkbox disabled 
                  v-for="dict in cl_talent_type"
                  :key="dict.value"
                  :label="dict.value">
                  {{dict.label}}
                </el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="服务类别" prop="serviceType">
              <el-checkbox-group v-model="form.serviceType">
                <el-checkbox disabled 
                  v-for="dict in cl_team_service_type"
                  :key="dict.value"
                  :label="dict.value">
                  {{dict.label}}
                </el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="服务时间" prop="serviceTime">
              <el-checkbox-group v-model="form.serviceTime">
                <el-checkbox disabled 
                  v-for="dict in cl_service_time"
                  :key="dict.value"
                  :label="dict.value">
                  {{dict.label}}
                </el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="服务领域或行业" prop="serviceField">
              <el-checkbox-group v-model="form.serviceField">
                <el-checkbox disabled 
                  v-for="dict in cl_service_field"
                  :key="dict.value"
                  :label="dict.value">
                  {{dict.label}}
                </el-checkbox>
              </el-checkbox-group>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label=" 性别" prop="sex">
              <el-select v-model="form.sex" placeholder="" disabled>
                <el-option
                  v-for="dict in cl_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="生日" prop="birthday">
              <el-date-picker clearable disabled
                v-model="form.birthday"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所在城市" prop="city">
              <el-input v-model="form.city" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所在行业" prop="industry">
              <el-input v-model="form.industry" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="所在单位" prop="company">
              <el-input v-model="form.company" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="邮箱" prop="email">
              <el-input v-model="form.email" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="自我介绍" prop="introduction">
              <el-input v-model="form.introduction" type="textarea" placeholder="" :autosize="{ minRows: 6, maxRows: 20 }" readonly input-style="color: #409eff;"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="手机号码" prop="mobile">
              <el-input v-model="form.mobile" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="身份证号码" prop="idCard">
              <el-input v-model="form.idCard" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>      
          </el-col>  
          <el-col :span="8">
            <el-form-item label="注册时间" prop="regTime">
              <el-date-picker clearable disabled
                v-model="form.regTime"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="地址" prop="address">
              <el-input v-model="form.address" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="居住地所在区域" prop="area">
              <el-input v-model="form.area" placeholder="" readonly input-style="color: #409eff;"/>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="已审核通过" prop="status">
              <el-select v-model="form.status" placeholder="" disabled>
                <el-option
                  v-for="dict in cl_examine_status"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="false">
            <el-form-item label="备注" prop="remark" >
              <el-input v-model="form.remark" type="textarea" placeholder="" />
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="false">
            <el-form-item label="最后登录时间" prop="lastLogin">
              <el-date-picker clearable
                v-model="form.lastLogin"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="false">
            <el-form-item label="最后登录ip" prop="lastIp">
              <el-input v-model="form.lastIp" placeholder="" />
            </el-form-item>
          </el-col>
  
          <el-col :span="6" v-if="false">
            <el-form-item label="是否被锁定冻结" prop="isLock">
              <el-input v-model="form.isLock" placeholder="" />
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="false">
            <el-form-item label="判断由哪个成员介绍进入" prop="firstLeader">
              <el-input v-model="form.firstLeader" placeholder="" />
            </el-form-item>
          </el-col>
          <el-col :span="6" v-if="false">
            <el-form-item label="用于app 授权类似于session_id" prop="token">
              <el-input v-model="form.token" placeholder="" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="success" @click="handleExaminePrePass(form)" v-hasPermi="['ndpf:member:edit']" v-if="form.status == '0'">通过</el-button>
          <el-button type="warning" @click="handleExamineRefuse(form)" v-hasPermi="['ndpf:member:edit']" v-if="form.status == '0'">驳回</el-button>
          <el-button @click="cancel">关 闭</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Member">
import { listMember, getMember, delMember, addMember, updateMember, listTeamMember, delTeamMember, examinePrePass, examineRefuse, findClTeamMember } from "@/api/ndpf/member";

const { proxy } = getCurrentInstance();
const { cl_sex, cl_member_level, cl_common_status, cl_service_time, cl_talent_type, cl_member_edu, cl_service_field, cl_blood_type, cl_team_service_type, cl_political_type, cl_examine_status } = proxy.useDict('cl_sex', 'cl_member_level', 'cl_common_status', 'cl_service_time', 'cl_talent_type', 'cl_member_edu', 'cl_service_field', 'cl_blood_type', 'cl_team_service_type', 'cl_political_type', 'cl_examine_status');

const memberList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const memberNames = ref([]);
const teamMemberIds = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    memberName: null,
    password: null,
    memberLevel: null,
    memberEdu: null,
    memberNationality: null,
    nativePlace: null,
    bloodType: null,
    political: null,
    sex: null,
    birthday: null,
    city: null,
    industry: null,
    company: null,
    introduction: null,
    email: null,
    mobile: null,
    mobileValidated: null,
    idCard: null,
    idValidated: null,
    headPic: null,
    cardPhoto: null,
    photo: null,
    isLock: null,
    firstLeader: null,
    token: null,
    regTime: null,
    lastLogin: null,
    lastIp: null,
    idAudit: null,
    score: null,
    serviceTime: null,
    address: null,
    area: null,
    status: null,
  },
  rules: {
    memberEdu: [
      { required: true, message: "成员学历不能为空", trigger: "change" }
    ],
    status: [
      { required: true, message: "0未审核1审核启用2停用3删除不能为空", trigger: "change" }
    ],
  }
});

const { queryParams, form, rules } = toRefs(data);

/** 查询成员信息列表 */
function getList() {
  loading.value = true;
  listTeamMember(queryParams.value).then(response => {
    memberList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    memberId: null,
    userId: null,
    memberName: null,
    password: null,
    memberLevel: null,
    memberEdu: null,
    memberNationality: null,
    nativePlace: null,
    bloodType: null,
    political: null,
    talent: [],
    serviceType: [],
    serviceTime: [],
    serviceField: [],
    sex: null,
    birthday: null,
    city: null,
    industry: null,
    company: null,
    introduction: null,
    email: null,
    mobile: null,
    mobileValidated: null,
    idCard: null,
    idValidated: null,
    headPic: null,
    cardPhoto: null,
    photo: null,
    isLock: null,
    firstLeader: null,
    token: null,
    regTime: null,
    lastLogin: null,
    lastIp: null,
    idAudit: null,
    score: null,
    totalService: null,
    address: null,
    area: null,
    status: null,
    remark: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
    teamMemberId: null
  };
  proxy.resetForm("memberRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.memberId);
  memberNames.value = selection.map(item => item.memberName);
  teamMemberIds.value = selection.map(item => item.teamMemberId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加成员信息";
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _memberId = row.memberId
  const _teamId = row.teamId
  form.value.memberId = _memberId
  form.value.teamId = _teamId
  findClTeamMember(form.value).then(response => {
    form.value = response.data;
    form.value.talent = (form.value.talent || '').split(',');
    form.value.serviceType = (form.value.serviceType || '').split(',');
    form.value.serviceTime = (form.value.serviceTime || '').split(',');
    form.value.serviceField = (form.value.serviceField || '').split(',');
    open.value = true;
    title.value = "查看成员信息";
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["memberRef"].validate(valid => {
    if (valid) {
      form.value.talent = form.value.talent.join(",");
      form.value.serviceType = form.value.serviceType.join(",");
      form.value.serviceTime = form.value.serviceTime.join(",");
      form.value.serviceField = form.value.serviceField.join(",");
      if (form.value.memberId != null) {
        updateMember(form.value).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          open.value = false;
          getList();
        });
      } else {
        addMember(form.value).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          open.value = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const memberName = row.memberName;
  const memberId = row.memberId;
  const teamId = row.teamId;
  const userId = row.userId;
  // 将变量转换为JSON对象
  const jsonData = {
    memberId: memberId,
    teamId: teamId,
    userId: userId
  };
  proxy.$modal.confirm('是否确认删除成员信息编号为"' + memberName + '"的数据项？').then(function() {
    return delTeamMember(jsonData);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download('ndpf/member/export', {
    ...queryParams.value
  }, `member_${new Date().getTime()}.xlsx`)
}

/** 审核通过操作 */
function handleExaminePrePass(row) {
  const _memberNames = row.memberName || memberNames.value
  const _teamMemberIds = row.teamMemberId || teamMemberIds.value
  proxy.$modal.confirm('是否确认"' + _memberNames + '"预审批通过').then(function() {
    return examinePrePass(_teamMemberIds);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("预审批成功");
    cancel();
  }).catch(() => {});
}

/** 审核拒绝操作 */
function handleExamineRefuse(row) {
  const _memberNames = row.memberName || memberNames.value
  const _teamMemberIds = row.teamMemberId || teamMemberIds.value
  proxy.$modal.confirm('是否确认"' + _memberNames + '"审批驳回').then(function() {
    return examineRefuse(_teamMemberIds);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("驳回成功");
    cancel();
  }).catch(() => {});
}

getList();
</script>

<style scoped>
:deep(.el-input__inner) {
  background-color: #FFFFFF;
}

:deep(.el-input.is-disabled .el-input__inner) {
  -webkit-text-fill-color: #409eff;
}

/* 修改禁用状态下的复选框字体颜色 */
/* :deep(.el-checkbox.is-disabled .el-checkbox__label) {
  color: #409eff;
}  */

:deep(.el-checkbox.is-disabled.is-checked .el-checkbox__inner) {
  background-color: #66ff94 ; /* 自定义打勾背景色（例如红色） */
  border-color: #66ff94 ;     /* 自定义边框颜色 */
}

</style>
